#ifndef HELPER_H
#define HELPER_H

#include <QObject>
#include <QSqlQuery>
#include <QVariant>
#include <QSqlQueryModel>
#include "dbadapter.h"
#include "sqlquerymodel.h"

//creates SqlQueryModel and set it to a widget
#define SET_QUERY_DATA(widget,query) {\
	SqlQueryModel *mdl = new SqlQueryModel;\
	mdl->setQuery(query);\
	ui.widget->setModel(mdl);\
	}


//Class for static helper functions that needed by more than one class in program
class Helper : public QObject
{
	Q_OBJECT

public:
	Helper(QObject *parent);
	~Helper();

	static void exportLessonData(int lessonid);
	static void exportUnlessonData(bool markAsExported = false);
	static QModelIndex findInModelColumn(QAbstractItemModel * model, int value, int column);
	static int getIntFromModel(QAbstractItemModel * model, int row, int column = -1);
	static QString pathToTests(int lessontypenum, int variantnum, int modnum = 0);
	static void formatStringToDb(QString &str);

	//Db adapter object for use in dialogs
	static DBAdapter *dbadapter;

private:
	
};

#endif // HELPER_H
